import { listRiskTianyanchaUpdate } from '@/api/company/base/companyBase'

const state = {
  risk: {
    // 变更数据条数
    changeInfoCount: 0,
    // 新闻数据条数
    newsCount: 0,
    // 股东信息
    holderCount: 0,
    // 主要人员
    staffCount: 0,
    // 融资历史
    historyCount: 0,
    // 对外投资
    subsidiaryCount: 0,
    // 主要客户
    clientCount: 0,
    // 经营风险
    riskCount: 0,
    // 竞品信息
    competitor: 0,
    // 专利
    patents: 0
  }
}

const mutations = {
  UPDATE_BUSS_RISK_COUNT(state, data) {
    state.risk.changeInfoCount = data.changeInfoCount
    state.risk.holderCount = data.holderCount
    state.risk.newsCount = data.newsCount
    state.risk.staffCount = data.staffCount
    state.risk.historyCount = data.historyCount
    state.risk.subsidiaryCount = data.subsidiaryCount
    state.risk.clientCount = data.clientCount
    state.risk.riskCount = data.riskCount
    state.risk.competitor = data.competitor
    state.risk.patents = data.patents
  }
}

const actions = {
  async UPDATE_BUSS_RISK_COUNT({ commit }, data) {
    var res = await listRiskTianyanchaUpdate(data)
    if (res.code === 200) {
      commit('UPDATE_BUSS_RISK_COUNT', res.data)
    }
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
